package api

import (
	"demo/pkg/app"
	"demo/pkg/e"
	"demo/service/article_service"
	"github.com/gin-gonic/gin"
	"net/http"
	"strconv"
)

func GetList(c *gin.Context) {

}
func GetDetail(c *gin.Context) {
	id, err := strconv.Atoi(c.Param("id"))
	if err != nil {
		c.JSON(http.StatusOK, app.Response{
			Code: e.INVALID_PARAMS,
			Msg:  e.GetMsg(e.INVALID_PARAMS),
			Data: nil,
		})
		return
	}

	articleService := article_service.Article{ID: id}
	article, err := articleService.Get()
	if err != nil {
		c.JSON(http.StatusOK, app.Response{
			Code: e.ERROR,
			Msg:  err.Error(),
			Data: nil,
		})
		return
	}
	c.JSON(http.StatusOK, app.SuccessResponse{
		Data: article,
	})
}
